local joy__zhengnan = fk.CreateSkill {

  name = "joy__zhengnan",

  tags = {  },

}



joy__zhengnan:addEffect(fk.EnterDying, {
  name = "joy__zhengnan",
  anim_type = "drawcard",
  events = {fk.EnterDying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(joy__zhengnan.name) and (player:getMark(joy__zhengnan.name) == 0 or not table.contains(player:getMark(joy__zhengnan.name), target.id))
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getMark(joy__zhengnan.name)
    local n = 0
      if target == player and player:hasSkill(joy__zhengnan.name) then
        n = 1
      end
    if mark == 0 then mark = {} end
    table.insert(mark, target.id)
    room:setPlayerMark(player, joy__zhengnan.name, mark)
    if player:isWounded() then
      room:recover({
        who = player,
        num = 1+n,
        recoverBy = player,
        skillName = joy__zhengnan.name
      })
    end
    local choices = {"joy__wusheng", "joyex__dangxian", "ty_ex__zhiman"}
    for i = 3, 1, -1 do
      if player:hasSkill(choices[i], true) then
        table.removeOne(choices, choices[i])
      end
    end
    if #choices > 0 then
      player:drawCards(1+n, joy__zhengnan.name)
      local choice = room:askForChoice(player, choices, joy__zhengnan.name, "#joy__zhengnan-choice", true)
      room:handleAddLoseSkills(player, choice, nil)
    else
      player:drawCards(3+n, joy__zhengnan.name)
    end
  end,
})

return joy__zhengnan